package com.sam.spring.chapter3;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.ResourceLoader;

import com.sam.spring.chapter3.bean.ResourceBean;

public class ResourceLoaderAwareTest {
	@Test
	public void test() {
		ApplicationContext ctx = new ClassPathXmlApplicationContext(
				"chapter3/resourceLoaderAware.xml");
		ResourceBean resourceBean = ctx.getBean(ResourceBean.class);
		ResourceLoader loader = resourceBean.getResourceLoader();
		/**
		 * 注意此处“loader instanceof
		 * ApplicationContext”，说明了ApplicationContext就是个ResoureLoader
		 */
		Assert.assertTrue(loader instanceof ApplicationContext);
	}
}
